<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        <!-- JavaScript includes - jQuery and our own script.js -->
		<script src="${initParam.root }/jquery-1.8.3.js"></script>
		<script src="${initParam.root }/scripts/recipe/script.js"></script>
		<script type="text/javascript">
		 $(document).ready(function(){
			  $(".listTxt").hide();
			  $(".listImg").hover(function(){
				  $(this).find(".fp").css("zIndex","1");
				  $(this).children(".listTxt").show();
				  $(this).find(".fp").stop().animate({ opacity: 0.7 }, 200);
			  },
			  function(){
				  $(this).find(".fp").css("zIndex","7");
			   $(this).children(".listTxt").hide();
			   $(this).find(".fp").stop().animate({ opacity: 1.0 }, 200);
			  });
			
				//검색 결과 화면일 경우 검색 구분과 검색어를 표시한다.
				var s_type = "${requestScope.searchRecipeList.s_type }";
				var s_txt = "${requestScope.searchRecipeList.s_txt }";
				$("#searchType").val(s_type);
				$("#searchTxt").val(s_txt);
				
				//정렬 기준 : 최신,조회수,평점
				var order = "${requestScope.searchRecipeList.s_order }";
				var isBtn = false;
				setOrder();
			
				function search(){
					var r_type = "${requestScope.searchRecipeList.r_type }";
					//r_type=="all" : 전체 레시피
					if(r_type=="all"){
						/* if($("#searchTxt").val()==""){
							location.href="recipe.do?command=searchList&s_order="+order;
						}else{
							alert("검색값있음!");
						} */
						if(isBtn){
							//검색버튼 클릭(=키워드 검색)
							var searchTxt = $("#searchTxt").val();
							var searchType = $("#searchType").val();
							location.href="recipe.do?command=searchList&s_txt="+searchTxt+"&s_type="+searchType+"&s_order=r_no";
						}else{
							//정렬
							location.href="recipe.do?command=searchList&s_txt="+s_txt+"&s_type="+s_type+"&s_order="+order;
						}
					}else{
						if(isBtn){
							//검색버튼 클릭(=키워드 검색)
							var searchTxt = $("#searchTxt").val();
							var searchType = $("#searchType").val();
							location.href="recipe.do?command=searchListByWord&r_type="+r_type+"&s_txt="+searchTxt+"&s_type="+searchType+"&s_order=r_no";
						}else{
							//정렬
							location.href="recipe.do?command=searchListByWord&r_type="+r_type+"&s_txt="+s_txt+"&s_type="+s_type+"&s_order="+order;
						}
					}
			
				}//search
				$("#moreRecipe").click(function(){
					if("${requestScope.searchRecipeList.r_type }"=="all")
					location.href="recipe.do?command=bbomListBySearch&s_txt=${requestScope.searchRecipeList.s_txt }&s_type=${requestScope.searchRecipeList.s_type }&s_order="+order;
					else
						location.href="recipe.do?command=bbomListBySearchWord&s_txt=${requestScope.searchRecipeList.s_txt }&s_type=${requestScope.searchRecipeList.s_type }&r_type=${requestScope.searchRecipeList.r_type }&s_order="+order;
				});
	
				//정렬값 셋팅
				function setOrder(){
					if(order=="r_no"){
						$("#new").attr("src","${initParam.root }/img/bbom&search/main-bbom-01-mouseon.gif");
						$("#grade").attr("src","${initParam.root }/img/bbom&search/main-bbom-02.gif");
						$("#count").attr("src","${initParam.root }/img/bbom&search/main-bbom-03.gif");
		
					}else if(order=="r_grade"){
						$("#new").attr("src","${initParam.root }/img/bbom&search/main-bbom-01.gif");
						$("#grade").attr("src","${initParam.root }/img/bbom&search/main-bbom-02-mouseon.gif");
						$("#count").attr("src","${initParam.root }/img/bbom&search/main-bbom-03.gif");
	
					}else if(order=="r_cnt"){
						$("#new").attr("src","${initParam.root }/img/bbom&search/main-bbom-01.gif");
						$("#grade").attr("src","${initParam.root }/img/bbom&search/main-bbom-02.gif");
						$("#count").attr("src","${initParam.root }/img/bbom&search/main-bbom-03-mouseon.gif");

					}
				}//setOrder
				
				//찾기 버튼 클릭
				$("#findBtn").click(function(){
					var searchTxt = $("#searchTxt").val();
					if(searchTxt==""){
						alert("검색어를 입력하세요!");
					}else{
						isBtn = true;
						search();
					}
				});
				
				//최신순
				$("#new").click(function(){
					order = "r_no";
					setOrder();
					isBtn = false;
					search();
				});
				
				//평점순
				$("#grade").click(function(){
					order = "r_grade";
					setOrder();
					isBtn = false;
					search();
				});
				
				//조회순
				$("#count").click(function(){
					order = "r_cnt";
					setOrder();
					isBtn = false;
					search();
				});
			});
			  
</script>

     	<meta charset="utf-8" />
        <title>뽐내기 게시판</title>
        
        <!-- The stylesheet -->
        <link rel="stylesheet" href="${initParam.root}/css/search_styles.css" />
        
        <!-- Google Fonts -->
       <!--  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Rochester|Bree+Serif" /> -->
       	<header>
			<h2><img src="${initParam.root }/img/bbom&search/main-search-admin.gif" alt="RapidXHTML" /></h2>
		</header>
	<div id="recipesearch">
		<ul>
		  		<li>
		  			<select id="searchType" style="width: 100px; height: 19px; margin-left: -10px; margin-top: -10px;">
		  				<option value="1">제목</option>
		  				<option value="2">제목+내용</option>
		  				<option value="3">제목+내용+재료</option>
		  			</select>
		  		</li>
		  		<li><input type="text" id="searchTxt" name="searchTxt" class="seaechTxt" style="background-image: url(' ${initParam.root}/img/bbom&search/main-bbom-find.gif');"><img src="${initParam.root }/img/bbom&search/main-bbom-findBtn.gif" id="findBtn"></li>
		  		<li><img src="${initParam.root }/img/bbom&search/main-bbom-01-mouseon.gif" id="new"></li>
		  		<li><img src="${initParam.root }/img/bbom&search/main-bbom-02.gif" id="grade"></li>
		  		<li><img src="${initParam.root }/img/bbom&search/main-bbom-03.gif" id="count"></li>
		</ul>
	</div>

	<div id="main">
	<!-- 운영자 레시피 -->
	<ul id="carousel">

   		<c:forEach items="${requestScope.searchRecipeList.list_admin }" var="list_admin">
    		<c:if test="${list_admin.R_USER=='a' and list_admin.LIST=='1'}">
    			<li class="visible">
    				<div class="listImg" align="center">
					<span class="listTxt" onclick="parent.location='recipe.do?command=getContent&r_no=${list_admin.R_NO }&m_id=${list_admin.M_ID }&page=1'" style="cursor: pointer;">
					${list_admin.R_DATE }<br>
					조회수 : ${list_admin.R_CNT }<br>
					평점 : 
	<c:choose>
						<c:when test="${list_admin.R_GCNT>0 }">
							<c:if test="${list_admin.R_GRADE >4.5}">
							 <img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-5.png">
      						</c:if>
							<c:if test="${list_admin.R_GRADE >=4.5 and list_admin.R_GRADE<5}">
									 <img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-4.5.png">
      						</c:if>
      							<c:if test="${list_admin.R_GRADE >=4 and list_admin.R_GRADE<4.5}">
									 <img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-4.png">
      						</c:if>
      						<c:if test="${list_admin.R_GRADE >=3.5 and list_admin.R_GRADE<4}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-3.5.png">
      						</c:if>
      							<c:if test="${list_admin.R_GRADE >=3 and list_admin.R_GRADE<3.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-3.png">
      						</c:if>
      							<c:if test="${list_admin.R_GRADE >=2.5 and list_admin.R_GRADE<3}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-2.5.png">
      						</c:if>
      							<c:if test="${list_admin.R_GRADE >=2 and list_admin.R_GRADE<2.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-2.png">
      						</c:if>
      						<c:if test="${list_admin.R_GRADE >=1.5 and list_admin.R_GRADE<2}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-1.5.png">
      						</c:if>
      						<c:if test="${list_admin.R_GRADE >=1 and list_admin.R_GRADE<1.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-1.png">
      						</c:if>
      						<c:if test="${list_admin.R_GRADE >=0.5 and list_admin.R_GRADE<1}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-1.png">
      						</c:if>
      						<c:if test="${list_admin.R_GRADE >0 and list_admin.R_GRADE<0.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-0.5.png">
      						</c:if>
      						</c:when>
							<c:otherwise>
								<br>평가해주세요!
							</c:otherwise>
							</c:choose>
					</span>
    				<a href="recipe.do?command=getContent&r_no=${list_admin. R_NO }&page=1&m_id=${list_admin.M_ID}">
    					<img class="fp" src="${initParam.imgRoot }${list_admin.R_IMG_NEW }" alt="RapidXHTML" /></div>
    				</a>
    				<img alt="title" src="${initParam.root }/img/bbom&search/main-bbom-title.gif"><span class="ListTitle">${list_admin.R_TITLE }</span><br>
    				<img alt="writer" src="${initParam.root }/img/bbom&search/main-bbom-hat.jpg"><span class="ListWriter">${list_admin.R_WRITER }</span>
    				</li>
   			</c:if>
   		</c:forEach>
	</ul>
   <hr>
    	<img src="${initParam.root }/img/bbom&search/main-search-member.gif" alt="RapidXHTML" class="memberTile"/>
    	<input type="image"  src="${initParam.root }/img/bbom&search/main-search-more.gif"  id="moreRecipe" name="moreRecipe" value="더보기"  class="more">
    	
	







	<!-- 회원 레시피 첫줄 -->
	<ul id="carousel1">
		<c:forEach items="${requestScope.searchRecipeList.list_user }" var="list" >
        	<c:if test="${list.R_USER=='b' and list.LIST=='1'}">
				<li class="visible">
				<div class="listImg" align="center">
					<span class="listTxt" onclick="parent.location='recipe.do?command=getContent&r_no=${list.R_NO }&m_id=${list.M_ID }&page=1'" style="cursor: pointer;">
					${list.R_DATE }<br>
					조회수 : ${list.R_CNT }<br>
						평점 : 
	<c:choose>
						<c:when test="${list.R_GCNT>0 }">
							<c:if test="${list.R_GRADE >4.5}">
							 <img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-5.png">
      						</c:if>
							<c:if test="${list.R_GRADE >=4.5 and list.R_GRADE<5}">
									 <img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-4.5.png">
      						</c:if>
      							<c:if test="${list.R_GRADE >=4 and list.R_GRADE<4.5}">
									 <img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-4.png">
      						</c:if>
      						<c:if test="${list.R_GRADE >=3.5 and list.R_GRADE<4}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-3.5.png">
      						</c:if>
      							<c:if test="${list.R_GRADE >=3 and list.R_GRADE<3.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-3.png">
      						</c:if>
      							<c:if test="${list.R_GRADE >=2.5 and list.R_GRADE<3}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-2.5.png">
      						</c:if>
      							<c:if test="${list.R_GRADE >=2 and list.R_GRADE<2.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-2.png">
      						</c:if>
      						<c:if test="${list.R_GRADE >=1.5 and list.R_GRADE<2}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-1.5.png">
      						</c:if>
      						<c:if test="${list.R_GRADE >=1 and list.R_GRADE<1.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-1.png">
      						</c:if>
      						<c:if test="${list.R_GRADE >=0.5 and list.R_GRADE<1}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-1.png">
      						</c:if>
      						<c:if test="${list.R_GRADE >0 and list.R_GRADE<0.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-0.5.png">
      						</c:if>
      						</c:when>
							<c:otherwise>
								<br>평가해주세요!
							</c:otherwise>
							</c:choose>
					</span>
				<a href="recipe.do?command=getContent&r_no=${list.R_NO }&page=1&m_id=${list.M_ID}"><img class="fp" src="${initParam.imgRoot }${list.R_IMG_NEW }" alt="RapidXHTML" /></div></a><img alt="title" src="${initParam.root }/img/bbom&search/main-bbom-title.gif"> <span class="ListTitle">${list.R_TITLE }</span><br><img alt="writer" src="${initParam.root }/img/bbom&search/main-bbom-hat.jpg"><span class="ListWriter">${list.R_WRITER }</span></li>
			</c:if>
		</c:forEach>		
	</ul>
	<!-- 회원 레시피 둘째줄 -->
	<ul id="carousel2">
		<c:forEach items="${requestScope.searchRecipeList.list_user }" var="list" >
            <c:if test="${list.R_USER=='b' and list.LIST=='2'}">
        		<li class="visible">
        		<div class="listImg" align="center">
					<span class="listTxt" onclick="parent.location='recipe.do?command=getContent&r_no=${list.R_NO }&m_id=${list.M_ID }&page=1'" style="cursor: pointer;">
					${list.R_DATE }<br>
					조회수 : ${list.R_CNT }<br>
					평점 : 
		<c:choose>
						<c:when test="${list.R_GCNT>0 }">
							<c:if test="${list.R_GRADE >4.5}">
							 <img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-5.png">
      						</c:if>
							<c:if test="${list.R_GRADE >=4.5 and list.R_GRADE<5}">
									 <img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-4.5.png">
      						</c:if>
      							<c:if test="${list.R_GRADE >=4 and list.R_GRADE<4.5}">
									 <img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-4.png">
      						</c:if>
      						<c:if test="${list.R_GRADE >=3.5 and list.R_GRADE<4}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-3.5.png">
      						</c:if>
      							<c:if test="${list.R_GRADE >=3 and list.R_GRADE<3.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-3.png">
      						</c:if>
      							<c:if test="${list.R_GRADE >=2.5 and list.R_GRADE<3}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-2.5.png">
      						</c:if>
      							<c:if test="${list.R_GRADE >=2 and list.R_GRADE<2.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-2.png">
      						</c:if>
      						<c:if test="${list.R_GRADE >=1.5 and list.R_GRADE<2}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-1.5.png">
      						</c:if>
      						<c:if test="${list.R_GRADE >=1 and list.R_GRADE<1.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-1.png">
      						</c:if>
      						<c:if test="${list.R_GRADE >=0.5 and list.R_GRADE<1}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-1.png">
      						</c:if>
      						<c:if test="${list.R_GRADE >0 and list.R_GRADE<0.5}">
      							<img alt="grade" src="${initParam.root }/img/bbom&search/main-grade-0.5.png">
      						</c:if>
      						</c:when>
							<c:otherwise>
								<br>평가해주세요!
							</c:otherwise>
							</c:choose>
					</span>
        		<a href="recipe.do?command=getContent&r_no=${list.R_NO }&page=1&m_id=${list.M_ID}"><img class="fp" src="${initParam.imgRoot }${list.R_IMG_NEW }" alt="RapidXHTML" /></div></a><img alt="title" src="${initParam.root }/img/bbom&search/main-bbom-title.gif"> <span="ListTitle">${list.R_TITLE }</span><br><img alt="writer" src="${initParam.root }/img/bbom&search/main-bbom-hat.jpg"> <span class="ListWriter">${list.R_WRITER }</span></li>
        	</c:if>
		</c:forEach>
	</ul>
	
</div>


	
	
	